package com.ghh.encrypto.security;

public class PasswordEncryptionFactory {
	public static final String SINCE_ENCTYPTED_VERSION = "2.2";
	public static final String DES_ENCRYPTION_VERSION = "2.3.2";  //TODO move to App
	
	public static PasswordEncryption getEncryption(String version) {
		if (CommonUtilities.isEmpty(version)) {
			return null;
		}
		if (CommonUtilities.versionCompare(version, SINCE_ENCTYPTED_VERSION) >= 0 && CommonUtilities.versionCompare(version, DES_ENCRYPTION_VERSION) < 0) {
			return new Base64PasswordEncoder();
		}
		if (CommonUtilities.versionCompare(version, DES_ENCRYPTION_VERSION) >= 0) {
			return new DESPasswordEncryption();
		}
		return null;
	}
}
